#ifndef WINDOWS
#define WINDOWS
double getC(double x[], double y[], double sx, int m, int i);


double getD(double x[], double y[], double sx, int m, int i){
    if(i < 0)
        throw "getD has i < 0";
    double rez = (x[i] - sx);
    
    rez *= getC(x, y, sx, m, i);
    return rez;      
}

double getU(double x[], double y[], double sx, int m, int i){
    
    double rez = (x[i+m] - sx);
    
    rez *= getC(x, y, sx, m, i);
    return rez;
}

double getC(double x[], double y[], double sx, int m, int i){
    
    double rez = 1.0;
    
    if((x[i] - x[i+m]) == 0.0)
        throw "Wrong i and m";
    rez /= (x[i] - x[i+m]);
    
    double u, d;
    
    if((m - 1) == 0){
        d = y[i];
        u = y[i+1];
    }
    else {
        d = getD(x, y, sx, m - 1, i + 1);
        u = getU(x, y, sx, m - 1, i); 
    }
    double temp = d-u;
    rez = rez*temp;
    return rez;
    
}

struct change {
    int depth;
    int pos;
    double change;
    bool isUp;
};

double getval(double  x[], double y[], double sx, int n){
    int m = 1;
    double rez = sx;
    for(int i = 0; i < n - 1 ; i++){
        rez += getD(x, y, sx, m++, i);
    }
    return rez;
}



#endif
